﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Windows.Media;

namespace SLARToolKitWinPhoneSample
{
    public partial class Page2 : PhoneApplicationPage
    {
        public Page2()
        {
            InitializeComponent();

            string[] arr1 = new string[] { "McChicken", "Spicy Chicken McDeluxe", "Cheeseburger", "Big Mac", "Filet-O-Fish", "Chicken Burger", "Double Cheeseburger", "Ayam Goreng McD(Regular)", "Ayam Goreng McD(Spicy)","Chicken McNuggets","Bubur Ayam McD","French Fries" };
    
            string[] images = new string[] { "McChicken", "Spicy", "CheeseBurger", "BigMac", "FishBurger","chickenburger","doubleCheese","ayamR","ayamS","nugget","bubur","french" };

            for (int i = 0; i < arr1.Length; ++i)
            {
                List_row row = new List_row();
                row.title.Text = arr1[i];
               
                row.myimage.Source = (ImageSource)new ImageSourceConverter().ConvertFromString("BurgerImages/" + images[i] + ".png");
                BurgerList.Items.Add(row);

            }
           

            this.Loaded += new RoutedEventHandler(MainPage_Loaded);

        }

        private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {

        }
        /*private void BeverageList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // If selected item is null (no selection) do nothing
            if (BeverageList.SelectedItem == null)
                return;

            // Navigate to the new page
            NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.Relative));

            // Reset selected item to null (no selection)
            BeverageList.SelectedItem = null;
        }*/
        
     void BurgerList_SelectionChanged(object sender, SelectionChangedEventArgs args)
        {
            int BIndex = BurgerList.SelectedIndex + 1;
           
                switch(BIndex)
                {
                    case 1:
                    NavigationService.Navigate(new Uri("/Burger/B1.xaml", UriKind.Relative));
                    break;

                    case 2:
                    NavigationService.Navigate(new Uri("/Burger/B2.xaml", UriKind.Relative));
                    break;

                    case 3:
                    NavigationService.Navigate(new Uri("/Burger/B3.xaml", UriKind.Relative));
                    break;

                    case 4:
                    NavigationService.Navigate(new Uri("/Burger/B4.xaml", UriKind.Relative));
                    break;

                    case 5:
                    NavigationService.Navigate(new Uri("/Burger/B5.xaml", UriKind.Relative));
                    break;

                    case 6:
                    NavigationService.Navigate(new Uri("/Burger/B6.xaml", UriKind.Relative));
                    break;

                    case 7:
                    NavigationService.Navigate(new Uri("/Burger/B7.xaml", UriKind.Relative));
                    break;

                    case 8:
                    NavigationService.Navigate(new Uri("/Burger/B8.xaml", UriKind.Relative));
                    break;

                    case 9:
                    NavigationService.Navigate(new Uri("/Burger/B9.xaml", UriKind.Relative));
                    break;

                    case 10:
                    NavigationService.Navigate(new Uri("/Burger/B10.xaml", UriKind.Relative));
                    break;

                    case 11:
                    NavigationService.Navigate(new Uri("/Burger/B11.xaml", UriKind.Relative));
                    break;

                    case 12:
                    NavigationService.Navigate(new Uri("/Burger/B12.xaml", UriKind.Relative));
                    break;

                    default:
                        break;
                }
                
               
            
            /*
             * MessageBox.Show("List Item " + (BeverageList.SelectedIndex + 1) + " pressed.");
             * ListBoxItem lbi = ((sender as ListBox).SelectedItem as ListBoxItem);
            NavigationService.Navigate(new Uri("/Page1.xaml?selectedItem=", UriKind.Relative));
            NavigationService.Navigate(new Uri("/Page1.xaml?selectedItem=" + (BeverageList.SelectedItem as ListBoxItem).Name, UriKind.Relative));*/
        }


    }
}